package payment;

import gui.ExpectedAmount;

import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;

import javax.swing.UIManager;
import javax.swing.UIManager.LookAndFeelInfo;

import dto.MemberPayDTO;

public class Card extends UnicastRemoteObject implements IPaymentMethod {
	/**
	 * 
	 */
	private static final long serialVersionUID = 7329036810610450194L;
	private String account;
	private static double expectedAmount;
	private ExpectedAmount jFrame;
	
	public Card() throws RemoteException {
		super();
		expectedAmount = 0;
		try {
			for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
				if ("Nimbus".equals(info.getName())) {
					UIManager.setLookAndFeel(info.getClassName());
					break;
				}
			}
		} catch (Exception e) {
		}
		jFrame = new ExpectedAmount();
	}
	public Card(String account) throws RemoteException {
		super();
		this.account = account;
	}
	public String getAccount() {
		return account;
	}
	public void setAccount(String account) {
		this.account = account;
	}
	@Override
	public void pay(MemberPayDTO mpd) throws RemoteException {
		// TODO hay que implementarlo
	}
	
	public synchronized void addExpected(double amount) throws RemoteException {
		expectedAmount += amount;
		jFrame.changeAmount(expectedAmount);
	}
	
	@Override
	public String toString() {
		return "Card";
	}
}
